package com.yyg.boot.weather.web;

import cn.com.webxml.ArrayOfString;
import cn.com.webxml.WeatherWS;
import cn.com.webxml.WeatherWSSoap;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author 一一哥Sun
 * @Date Created in 2020/5/10
 * @Description Description
 */
@Slf4j
@RestController
public class WeatherController {

    @GetMapping("/weather")
    public List<String> getWeather() {
        WeatherWSSoap weatherWSSoap = new WeatherWS().getWeatherWSSoap();

        //获取国家信息
        ArrayOfString arrayOfString = weatherWSSoap.getRegionCountry();
        List<String> list = arrayOfString.getString();

        for (String result : list) {
            log.warn(result);
        }

        //获取省份
        ArrayOfString arrayOfString1 = weatherWSSoap.getRegionProvince();
        List<String> list1 = arrayOfString1.getString();
        for (String s : list1) {
            log.warn(s);
        }

        //获取城市-北京
        ArrayOfString arrayOfString2 = weatherWSSoap.getSupportCityString("311101");
        List<String> list2 = arrayOfString2.getString();
        for (String s : list2) {
            log.warn(s);
        }

        //获取天气需要账号
        ArrayOfString arrayOfString3 = weatherWSSoap.getWeather("上海", "7e376b5fd13241d49ae06ba3f1a624b6");
        List<String> list3 = arrayOfString3.getString();
        for (String s : list3) {
            log.warn(s);
        }

        return list3;
    }

}
